package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

	/**
	 * 根据菜品id查询菜品对应的套餐id有哪些
	 *
	 * @param dishIds
	 * @return
	 */
	List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

	/**
	 * 插入多条套餐包含菜品关系
	 *
	 * @param setmealDishes
	 */
	void insertBatch(List<SetmealDish> setmealDishes);

	/**
	 * 根据套餐id查询包含的菜品信息有哪些
	 *
	 * @param setmealId
	 * @return
	 */
	@Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
	List<SetmealDish> getBySetmealId(Long setmealId);

	@Delete("delete from setmeal_dish where setmeal_id=#{setmealID}")
	void deleteBySetmealId(Long setmealId);

	/**
	 * 根据套餐id查出包含的菜品名，份数，图片链接地址，描述
	 * @param setmealId
	 * @return
	 */
	@Select("select sd.name,sd.copies,d.image,d.description from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
			"where sd.setmeal_id = #{setmealId}")
	List<DishItemVO> getDishItemBySetmealId(Long setmealId);
}
